Sky, esse comando pode ser usado toda hora ?
Tem como por um delay , e tambem só poderia ativar sem battle?
Por SkyDangerous, 19 de jun. de 2012 em Mods, funções e outros
info
Grupo: Visconde
Registrado: 13/10/11
Posts: 411
Reputação: +65

Sky, esse comando pode ser usado toda hora ?
Tem como por um delay , e tambem só poderia ativar sem battle?
info
Grupo: Lorde
Registrado: 17/01/09
Posts: 2.1k
Reputação: +395
Char no Tibia: Adra Sata

Sky, esse comando pode ser usado toda hora ?
Tem como por um delay , e tambem só poderia ativar sem battle?
é isso que eu vou por depois.
kk', pra nao ficar toda hora trocando.
info
Grupo: Herói
Registrado: 25/10/11
Posts: 2.2k
Reputação: +862
Gênero: Masculino
Char no Tibia: Sociopata

e.e Muito Bom #@SkyDangerous ![]()
info
Grupo: Barão
Registrado: 18/10/10
Posts: 246
Reputação: +89
Char no Tibia: Elite Pamcadaum

Fico bacana Sky, Parabéns REP +;
Tipo, não usa FALSE nem TRUE cara, usa false e true, FALSE e TRUE são macros, não booleanos;
Poe ae um event onAttack também pra não poder atacar o cara, ai só vai previnir que o cara não tome o dano, e tipo a msg você poe só no onAttack, no onCombat não precisa porque se não vai ficar tipo, toda hora que o cara tentar hitar mandando a mensagem, mesmo se tiver sido um ataque em área!
info
Grupo: Herói
Registrado: 20/05/10
Posts: 3.4k
Reputação: +1.5k
Gênero: Masculino

fico bom, mas de vez de fazer por db, daria pra fazer por storage...
info
Grupo: Lorde
Registrado: 17/01/09
Posts: 2.1k
Reputação: +395
Char no Tibia: Adra Sata

e.e Muito Bom #@SkyDangerous
Vlw ![]()
Fico bacana Sky, Parabéns REP +;
Tipo, não usa FALSE nem TRUE cara, usa false e true, FALSE e TRUE são macros, não booleanos;
Poe ae um event onAttack também pra não poder atacar o cara, ai só vai previnir que o cara não tome o dano, e tipo a msg você poe só no onAttack, no onCombat não precisa porque se não vai ficar tipo, toda hora que o cara tentar hitar mandando a mensagem, mesmo se tiver sido um ataque em área!
Ok, irei modificar.
Vlw
fico bom, mas de vez de fazer por db, daria pra fazer por storage...
Sim, eu já fiz por storage.. é bem parecido ;D
info
Grupo: Cavaleiro
Registrado: 19/06/11
Posts: 195
Reputação: +14
Char no Tibia: Desconhecido

Teria como fazer pra um npc ativar e desativar o PVP? e assim que o player ativasse o PVP ele ganha uma skull amarela?
To com um erro aqui ao adicionar o código no SQL
Error while executing query: Cannot add a NOT NULL column with default value NULL
info
Grupo: Herói
Registrado: 20/05/10
Posts: 3.4k
Reputação: +1.5k
Gênero: Masculino

Se eu não me engano tem um bug, porque os dois jogadores tem que ta usando pra não poderem se atacar, ou seja se JOÃO tiver no modo seguro e MARIA não, MARIA ainda vai poder atacar o JOÃO... usa assim:
query:
ALTER TABLE `players` ADD `pvpmode` INT NOT NULL DEFAULT '0'
e script fiz em MODS
PvpMode.xml
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Pvp Mode" version="1.0" author="Gevox" contact="xtibia.com" enabled="yes">
<config name="pvpmode_func"><![CDATA[
function getPlayerPVPMode(cid)
local check = db.getResult("SELECT `pvpmode` FROM `players` WHERE `id` = " .. getPlayerGUID(cid) .. " LIMIT 1")
return check:getDataInt("pvpmode") <= 0 and 0 or check:getDataInt("pvpmode")
end
function setPlayerPVPMode(cid, value)
db.executeQuery("UPDATE `players` SET `pvpmode` = "..value.." WHERE `id` = "..getPlayerGUID(cid))
end
]]></config>
<talkaction words="/pvp;!pvp" event="buffer"><![CDATA[
domodlib('pvpmode_func')
if isPlayerPzLocked(cid) == FALSE and getCreatureSkullType(cid) == SKULL_NONE then
setPlayerPVPMode(cid, getPlayerPVPMode(cid) == 0 and 1 or 0)
doPlayerSendTextMessage(cid, 19, "Now you set pvp mode to "..(getPlayerPVPMode(cid) == 0 and "off" or "on").."!")
else
doPlayerSendCancel(cid, "You cannot set pvp mode when you are agressive.")
end
return true
]]></talkaction>
<event type="login" name="PvpModeRegister" event="script"><![CDATA[
function onLogin(cid)
registerCreatureEvent(cid, "pvpProtection")
return true
end]]></event>
<event type="combat" name="pvpProtection" event="script"><![CDATA[
domodlib('pvpmode_func')
if isPlayer(cid) and isPlayer(target) then
if getPlayerPVPMode(cid) == 1 or getPlayerPVPMode(target) == 1 then
doPlayerSendCancel(cid, "You may not attack this player.")
return false
end
end
return true
]]></event>
</mod>
obs: ainda prefiro fazer por storage
Editado Junho 20 por Vodkart
info
Grupo: Artesão
Registrado: 25/03/12
Posts: 109
Reputação: +4
Char no Tibia: Kimera DebochadoOo

O nosso querido jhon992 fez um pra min com stogare como disse o Vodkart eu achei mais pratico.
info
Grupo: Cavaleiro
Registrado: 19/06/11
Posts: 195
Reputação: +14
Char no Tibia: Desconhecido

Funcinou tem como assim que o player ativar o PVP ele ganhar uma Yellow Skull?
info
Grupo: Herói
Registrado: 20/05/10
Posts: 3.4k
Reputação: +1.5k
Gênero: Masculino

Funcinou tem como assim que o player ativar o PVP ele ganhar uma Yellow Skull?
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Pvp Mode" version="1.0" author="Gevox" contact="xtibia.com" enabled="yes">
<config name="pvpmode_func"><![CDATA[
function getPlayerPVPMode(cid)
local check = db.getResult("SELECT `pvpmode` FROM `players` WHERE `id` = " .. getPlayerGUID(cid) .. " LIMIT 1")
return check:getDataInt("pvpmode") <= 0 and 0 or check:getDataInt("pvpmode")
end
function setPlayerPVPMode(cid, value)
db.executeQuery("UPDATE `players` SET `pvpmode` = "..value.." WHERE `id` = "..getPlayerGUID(cid))
end
]]></config>
<talkaction words="/pvp;!pvp" event="buffer"><![CDATA[
domodlib('pvpmode_func')
if isPlayerPzLocked(cid) == FALSE and isInArray({SKULL_NONE,SKULL_YELLOW}, getCreatureSkullType(cid)) then
setPlayerPVPMode(cid, getPlayerPVPMode(cid) == 0 and 1 or 0)
doCreatureSetSkullType(cid, getPlayerPVPMode(cid) == 1 and 1 or 0)
doPlayerSendTextMessage(cid, 19, "Now you set pvp mode to "..(getPlayerPVPMode(cid) == 0 and "off" or "on").."!")
else
doPlayerSendCancel(cid, "You cannot set pvp mode when you are agressive.")
end
return true
]]></talkaction>
<event type="login" name="PvpModeRegister" event="script"><![CDATA[
domodlib('pvpmode_func')
function onLogin(cid)
registerCreatureEvent(cid, "pvpProtection")
if getPlayerPVPMode(cid) == 1 then doCreatureSetSkullType(cid, 1) end
return true
end]]></event>
<event type="combat" name="pvpProtection" event="script"><![CDATA[
domodlib('pvpmode_func')
if isPlayer(cid) and isPlayer(target) then
if getPlayerPVPMode(cid) == 1 or getPlayerPVPMode(target) == 1 then
doPlayerSendCancel(cid, "You may not attack this player.")
return false
end
end
return true
]]></event>
</mod>
Editado Junho 20 por Vodkart
info
Grupo: Cavaleiro
Registrado: 19/06/11
Posts: 195
Reputação: +14
Char no Tibia: Desconhecido

Outra pergunta tem como fazer isso so que por NPC?
info
Grupo: Herói
Registrado: 20/05/10
Posts: 3.4k
Reputação: +1.5k
Gênero: Masculino

óbvio que tem, você diz trocar a talk por npc né.
info
Grupo: Lorde
Registrado: 17/01/09
Posts: 2.1k
Reputação: +395
Char no Tibia: Adra Sata
Função:
Você pode alterar o seu tipo de pvp, utilizando o comando !pvp on, para conseguirem te atacar e !pvp off para não te atacarem
SQL QUERY
em data/lib/function.lua
function getPlayerPVPMode(uid) local result = db.getResult("SELECT `pvpmode` FROM `players` WHERE `name` = '" .. getPlayerName(uid) .. "' LIMIT 1;") if(result:getID() ~= -1) then local mode = result:getDataInt("pvpmode") return mode else return FALSE end result:free() end function setPlayerPVPMode(uid, value) if (value >= 0 and value <= 1) then if isPlayer(uid) == TRUE then db.executeQuery("UPDATE `players` SET `pvpmode` = " .. value .. " WHERE `name`='" .. getPlayerName(uid) .. "' LIMIT 1;") return TRUE else return FALSE end else return FALSE end enddata/talkactions/scripts/pvpmode.lua
function onSay(cid, words, param) local mode = getPlayerPVPMode(cid) if mode == 1 then setMode = 0 else setMode = 1 end if isPlayerPzLocked(cid) == FALSE and getCreatureSkullType(cid) == SKULL_NONE then setPlayerPVPMode(cid, setMode) if setMode == 1 then doPlayerSendTextMessage(cid, 19, "Now you set pvp mode to on!") else doPlayerSendTextMessage(cid, 19, "Now you set pvp mode to off!") end else doPlayerSendCancel(cid, "You cannot set pvp mode when you are agressive.") end return TRUE endtalkactions.xml
login.lua
data/creaturescripts/scripts/pvpProtection.lua
function onCombat(cid, target) if (getPlayerPVPMode(cid) == 1 and getPlayerPVPMode(target) == 1) or isPlayer(target) == FALSE then return TRUE else doPlayerSendCancel(cid, "You cannot attack players which pvp mode is off.") return FALSE end endcreaturescripts.xml
</event></talkaction>
Credits
Gevox
Editado Junho 19 por SkyDangerous